#include <iostream>
#include <gtest/gtest.h>
#include <unordered_map>

class MyTest : public testing::Test
{
public:
    static void SetUpTestSuite()
    {
        std::cout << "所有单元测试前执行，初始化总环境" << std::endl;
        //假设有全局数据容器，在这里插入公共测试数据
    }
    void SetUp()
    {
        //在这里插入每个单元测试所需的独立测试数据
        std::cout << "单元测试初始化" << std::endl;

        _mymap.insert({"hello", "你好"});
        _mymap.insert({"bye", "再见"});
        
    }
    void TearDown()
    {
        //在这里清理每个单元测试的数据
        std::cout << "单元测试清理" << std::endl;

        _mymap.clear();
    }
    static void TearDownTestSuite()
    {
        //清理公共测试数据
        std::cout << "所有单元测试完成后执行，清理总环境" << std::endl;
    }

public:
    std::unordered_map<std::string, std::string> _mymap;
};
TEST_F(MyTest, insert_test)
{
    _mymap.insert({"leihou", "你好"});
    ASSERT_EQ(_mymap.size(), 3);

}

TEST_F(MyTest, size_test)
{
    ASSERT_EQ(_mymap.size(), 2);
}

int main(int argc, char *argv[])
{
    testing::InitGoogleTest(&argc, argv);
    int ret = RUN_ALL_TESTS();
    (void)ret;
    return 0;
}
